﻿using Microsoft.AspNetCore.Mvc;

public class MainController : IDynamicApiController
{
    private readonly MainService _mainService;
    private readonly RequestService _requestService;

    public MainController(MainService mainService, RequestService requestService)
    {
        _mainService = mainService;
        _requestService = requestService;
    }

    /// <summary>
    /// 门店列表
    /// </summary>
    /// <returns></returns>
    [HttpPost("ShopList")]
    public dynamic GetShopList(ParamsDto paramsDto)
    {
        var pageDto = _mainService.GetShopList(paramsDto);
        return pageDto;
    }

    /// <summary>
    /// 省份下拉框
    /// </summary>
    /// <returns></returns>
    [HttpGet("ProvinceSelect")]
    public dynamic GetProvinceSelect()
    {
        var list = _mainService.GetProvinceSelect();
        return list;
    }

    /// <summary>
    /// 城市下拉框
    /// </summary>
    /// <returns></returns>
    [HttpGet("CitySelect")]
    public dynamic GetCitySelect([FromQuery] string province)
    {
        var list = _mainService.GetCitySelect(province);
        return list;
    }

    /// <summary>
    /// 人员列表
    /// </summary>
    /// <returns></returns>
    [HttpPost("UserList")]
    public dynamic GetUserList(ParamsDto paramsDto)
    {
        var pageDto = _mainService.GetUserList(paramsDto);
        return pageDto;
    }

    /// <summary>
    /// 日志列表
    /// </summary>
    /// <returns></returns>
    [HttpPost("LogList")]
    public dynamic GetLogList(ParamsDto paramsDto)
    {
        var pageDto = _mainService.GetLogList(paramsDto);
        return pageDto;
    }

    /// <summary>
    /// 商品列表
    /// </summary>
    /// <returns></returns>
    [HttpPost("ProductList")]
    public dynamic GetProductList(ParamsDto paramsDto)
    {
        var pageDto = _mainService.GetProductList(paramsDto);
        return pageDto;
    }

    /// <summary>
    /// 更新商品信息
    /// </summary>
    /// <returns></returns>
    [HttpGet("RequestProduct")]
    public async Task AddOrUpdateProductAsync()
    {
        await _mainService.AddOrUpdateProductAsync();
    }

    /// <summary>
    /// 向手机号发送验证码
    /// </summary>
    /// <param name="phone"></param>
    /// <returns></returns>
    [HttpGet("SendCode")]
    public async Task SendCode(string phone)
    {
        await _requestService.SendCode(phone);
    }

    /// <summary>
    /// 向手机号发送验证码
    /// </summary>
    /// <param name="phone"></param>
    /// <param name="code"> </param>
    /// <returns></returns>
    [HttpGet("Login")]
    public async Task Login([FromQuery] string phone, [FromQuery] string code)
    {
        await _mainService.Login(phone, code);
    }

    /// <summary>
    /// 更新门店信息
    /// </summary>
    /// <returns></returns>
    [HttpGet("RequestShop")]
    public async Task AddOrUpdateShopAsync()
    {
        await _mainService.AddOrUpdateShopAsync();
    }

    /// <summary>
    /// 批量预约
    /// </summary>
    [HttpGet("ReservationBatch")]
    public async Task<dynamic> ReservationBatch([FromQuery] string mobile = "")
    {
        return await _mainService.ReservationBatch(mobile);
    }

    /// <summary>
    /// 删除
    /// </summary>
    [HttpGet("Delete")]
    public void DeleteUser([FromQuery] string mobile = "")
    {
        _mainService.DeleteUser(mobile);
    }

    /// <summary>
    /// 更新
    /// </summary>
    [HttpPost("Update")]
    public void UpdateUser(UpdateUserInput input)
    {
        _mainService.UpdateUser(input);
    }
}